/**
 * 	 Copyright (c) 2008, 2009 Lukas Zaruba
 * 
 *   This file is part of UniAnalyzer (Universal Analyzer).
 *
 *   UniAnalyzer is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   UniAnalyzer is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with UniAnalyzer. If not, see <http://www.gnu.org/licenses/>.
 */

package net.zarubsys.unianalyzer.dataminers.lpt.pin;

import java.io.Serializable;

public class CustomizedPin implements IPin, Serializable, Cloneable {
	private static final long serialVersionUID = 4852693691054340793L;
	
	private final IPin internalPin;
	private String customizedName = ""; //$NON-NLS-1$
	private boolean checked = true;

	public CustomizedPin(IPin internalPin) {
		this.internalPin = internalPin;
		this.checked = !internalPin.isReserved();
	}
	
	public String getCustomizedName() {
		return customizedName;
	}

	public void setCustomizedName(String customizedName) {
		this.customizedName = customizedName;
	}

	public boolean isChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}
	
	public String getCustomizedLabel() {
		StringBuilder sb = new StringBuilder();
		sb.append(internalPin.getNumber()).append(" - "). //$NON-NLS-1$
			append(customizedName).append(" (").append(internalPin.getDescription()). //$NON-NLS-1$
			append(")"); //$NON-NLS-1$
		return sb.toString(); 
	}

	
	public String getDescription() {
		return internalPin.getDescription();
	}

	
	public String getLabel() {
		return internalPin.getLabel();
	}

	
	public int getNumber() {
		return internalPin.getNumber();
	}

	
	public int getOffset() {
		return internalPin.getOffset();
	}

	
	public int getOrderInByte() {
		return internalPin.getOrderInByte();
	}

	
	public boolean isReserved() {
		return internalPin.isReserved();
	}
	
	
	public int hashCode() {
		int hash = 17;
		hash ^= customizedName.hashCode();
		hash *= 13 ^ internalPin.getOffset();
		hash *= 17 ^ internalPin.getOrderInByte();
		hash *= 19 ^ internalPin.getNumber();
		if (checked) {
			hash ^= 57;
		}
		return hash;
	}
	
	
	public Object clone() throws CloneNotSupportedException {
		return super.clone();
	}

}


/*
 * $Log$
 */